package com.iversonx.observer.example_1.v1;

import com.iversonx.observer.example_1.service.MinibusTargetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 **/
@Service
public class LotteryService {
    
    @Autowired
    private MinibusTargetService minibusTargetService;
    
    @Autowired
    private SmsService smsService;
    
    @Autowired
    private MQService mqService;
    
    public void doDraw(String uId) {
        // 摇号
        String lottery = minibusTargetService.lottery(uId);
        // 发短信通知用户
        smsService.send("给⽤户 " + uId + " 发送短信通知(短信)：" + lottery);
        // 发至MQ，记录结果
        mqService.send("记录⽤户 " + uId + " 摇号结果(MQ)：" + lottery);
    }
}
